
#include <stdio.h>

int main()
{
	long	t, n, r; 
	long	i, b; 
	char	s[30]; 
	
	scanf("%ld %ld", &n, &r); 
	t = n; 
	//printf("n=%ld, r=%ld\n", n, r); 
	for (i=0; i<30; i++) {
		b = (t % r); 
		t /= r; 
		if (b<0) {
			b -= r; 
			t++; 
		}			
		//printf("  i=%ld: t=%ld b=%ld\n", i, t, b); 
		s[i] = (b>=10 ? b - 10 + 'A' : b + '0'); 
		if (t==0) 
			break; 
	}
	//printf("i=%ld\n", i);
	printf("%ld=", n); 
	while(i>=0) {
		printf("%c", s[i]); 
		i--; 
	}
	printf("(base%ld)\n", r); 
	
	return 0; 
}



